package cn.jekun.web.shop.service;

import java.sql.Types;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import cn.jekun.component.base.bean.Page;
import cn.jekun.component.base.utils.SqlUtis;
import cn.jekun.component.base.validator.annotation.NotBlank;
import cn.jekun.component.core.bean.gen.ErpCart;
import cn.jekun.component.core.bean.gen.ErpMerchandise;
import cn.jekun.component.core.bean.gen.ErpShop;

@Service(CartService.BEAN_NAME)
public class CartService extends ShopBaseService{
	public static final String BEAN_NAME="cn.jekun.web.shop.service.CartService";
	@Override
	public String getNamespace() {
		return "SHOP_ADMIN_ERP_CART";
	}
	/**
	 * 获取列表
	 * @return
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public List<ErpCart> getCartList(
			@ErpShop.AnnoMobile String mobile,
			@ErpMerchandise.AnnoMerchandiseName String merchandiseName,
			@ErpShop.AnnoShopId String shopId,
			@NotBlank Page page){
		Map formMap=new HashMap<String, String>();
		formMap.put(ErpShop.COL_MOBILE, mobile);
		formMap.put(ErpMerchandise.COL_MERCHANDISE_NAME, merchandiseName);
		formMap.put( ErpShop.COL_SHOP_ID,shopId );
		
		SqlUtis.prepareSql(formMap,
				SqlUtis.getSQL(formMap, "d." + ErpShop.COL_MOBILE, Types.VARCHAR, SqlUtis.LIKE)
				,SqlUtis.getSQL(formMap, "a." + ErpShop.COL_SHOP_ID, Types.VARCHAR, SqlUtis.EQ)
				,SqlUtis.getSQL(formMap, "b." + ErpMerchandise.COL_MERCHANDISE_NAME, Types.VARCHAR, SqlUtis.LIKE)
				);
		return this.list("SHOP_ADMIN_ERP_CART.cartList",formMap, page);
	}
}
